package com.yicong.ants.bean.circle;

import com.cchao.simplelib.LibCore;
import com.cchao.simplelib.core.JsonHelper;
import com.cchao.simplelib.util.StringHelper;
import com.yicong.ants.utils.JsonUtils;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author cch
 * @version 2020/11/3
 */
public class AdItem extends ArticleItem {

    public static Map<String, String> Code_Map;

    static {
        String json = JsonUtils.getJson(LibCore.getContext(), "code.json");
        Code_Map = JsonHelper.toMap(json, String.class);
    }

    private String img_url;
    private String total_times;
    private String today_click;
    private String click_times;
    private String unit_price;
    private int style;
    private int check_status;
    private String refund_status;
    private String refund_coin;
    private String age_text;
    private String gender_text;
    private String address_1;
    private String address_2;
    private String address_3;
    private String address_text;

    public AdItem() {
    }

    public String getAddress_text() {
        List<String> list = new ArrayList<>();
        if (StringHelper.isNotEmpty(address_1)) {
            list.add(Code_Map.get(address_1));
        }
        if (StringHelper.isNotEmpty(address_2) && !address_2.equals("-1")) {
            list.add(Code_Map.get(address_2));
        }
        if (StringHelper.isNotEmpty(address_3) && !address_3.equals("-1")) {
            list.add(Code_Map.get(address_3));
        }
        address_text = StringUtils.join(list.toArray(), ",");
        if (StringHelper.isEmpty(address_text)) {
            return "全国投放";
        }
        return address_text;
    }

    public String getImg_url() {
        return this.img_url;
    }

    public String getTotal_times() {
        return this.total_times;
    }

    public String getToday_click() {
        return this.today_click;
    }

    public String getClick_times() {
        return this.click_times;
    }

    public String getUnit_price() {
        return this.unit_price;
    }

    public int getStyle() {
        return this.style;
    }

    public int getCheck_status() {
        return this.check_status;
    }

    public String getRefund_status() {
        return this.refund_status;
    }

    public String getRefund_coin() {
        return this.refund_coin;
    }

    public String getAge_text() {
        return this.age_text;
    }

    public String getGender_text() {
        return this.gender_text;
    }

    public String getAddress_1() {
        return this.address_1;
    }

    public String getAddress_2() {
        return this.address_2;
    }

    public String getAddress_3() {
        return this.address_3;
    }

    public void setImg_url(String img_url) {
        this.img_url = img_url;
    }

    public void setTotal_times(String total_times) {
        this.total_times = total_times;
    }

    public void setToday_click(String today_click) {
        this.today_click = today_click;
    }

    public void setClick_times(String click_times) {
        this.click_times = click_times;
    }

    public void setUnit_price(String unit_price) {
        this.unit_price = unit_price;
    }

    public void setStyle(int style) {
        this.style = style;
    }

    public void setCheck_status(int check_status) {
        this.check_status = check_status;
    }

    public void setRefund_status(String refund_status) {
        this.refund_status = refund_status;
    }

    public void setRefund_coin(String refund_coin) {
        this.refund_coin = refund_coin;
    }

    public void setAge_text(String age_text) {
        this.age_text = age_text;
    }

    public void setGender_text(String gender_text) {
        this.gender_text = gender_text;
    }

    public void setAddress_1(String address_1) {
        this.address_1 = address_1;
    }

    public void setAddress_2(String address_2) {
        this.address_2 = address_2;
    }

    public void setAddress_3(String address_3) {
        this.address_3 = address_3;
    }

    public void setAddress_text(String address_text) {
        this.address_text = address_text;
    }

    public boolean equals(final Object o) {
        if (o == this) return true;
        if (!(o instanceof AdItem)) return false;
        final AdItem other = (AdItem) o;
        if (!other.canEqual((Object) this)) return false;
        if (!super.equals(o)) return false;
        final Object this$img_url = this.getImg_url();
        final Object other$img_url = other.getImg_url();
        if (this$img_url == null ? other$img_url != null : !this$img_url.equals(other$img_url))
            return false;
        final Object this$total_times = this.getTotal_times();
        final Object other$total_times = other.getTotal_times();
        if (this$total_times == null ? other$total_times != null : !this$total_times.equals(other$total_times))
            return false;
        final Object this$today_click = this.getToday_click();
        final Object other$today_click = other.getToday_click();
        if (this$today_click == null ? other$today_click != null : !this$today_click.equals(other$today_click))
            return false;
        final Object this$click_times = this.getClick_times();
        final Object other$click_times = other.getClick_times();
        if (this$click_times == null ? other$click_times != null : !this$click_times.equals(other$click_times))
            return false;
        final Object this$unit_price = this.getUnit_price();
        final Object other$unit_price = other.getUnit_price();
        if (this$unit_price == null ? other$unit_price != null : !this$unit_price.equals(other$unit_price))
            return false;
        if (this.getStyle() != other.getStyle()) return false;
        if (this.getCheck_status() != other.getCheck_status()) return false;
        final Object this$refund_status = this.getRefund_status();
        final Object other$refund_status = other.getRefund_status();
        if (this$refund_status == null ? other$refund_status != null : !this$refund_status.equals(other$refund_status))
            return false;
        final Object this$refund_coin = this.getRefund_coin();
        final Object other$refund_coin = other.getRefund_coin();
        if (this$refund_coin == null ? other$refund_coin != null : !this$refund_coin.equals(other$refund_coin))
            return false;
        final Object this$age_text = this.getAge_text();
        final Object other$age_text = other.getAge_text();
        if (this$age_text == null ? other$age_text != null : !this$age_text.equals(other$age_text))
            return false;
        final Object this$gender_text = this.getGender_text();
        final Object other$gender_text = other.getGender_text();
        if (this$gender_text == null ? other$gender_text != null : !this$gender_text.equals(other$gender_text))
            return false;
        final Object this$address_1 = this.getAddress_1();
        final Object other$address_1 = other.getAddress_1();
        if (this$address_1 == null ? other$address_1 != null : !this$address_1.equals(other$address_1))
            return false;
        final Object this$address_2 = this.getAddress_2();
        final Object other$address_2 = other.getAddress_2();
        if (this$address_2 == null ? other$address_2 != null : !this$address_2.equals(other$address_2))
            return false;
        final Object this$address_3 = this.getAddress_3();
        final Object other$address_3 = other.getAddress_3();
        if (this$address_3 == null ? other$address_3 != null : !this$address_3.equals(other$address_3))
            return false;
        final Object this$address_text = this.getAddress_text();
        final Object other$address_text = other.getAddress_text();
        if (this$address_text == null ? other$address_text != null : !this$address_text.equals(other$address_text))
            return false;
        return true;
    }

    protected boolean canEqual(final Object other) {
        return other instanceof AdItem;
    }

    public int hashCode() {
        final int PRIME = 59;
        int result = super.hashCode();
        final Object $img_url = this.getImg_url();
        result = result * PRIME + ($img_url == null ? 43 : $img_url.hashCode());
        final Object $total_times = this.getTotal_times();
        result = result * PRIME + ($total_times == null ? 43 : $total_times.hashCode());
        final Object $today_click = this.getToday_click();
        result = result * PRIME + ($today_click == null ? 43 : $today_click.hashCode());
        final Object $click_times = this.getClick_times();
        result = result * PRIME + ($click_times == null ? 43 : $click_times.hashCode());
        final Object $unit_price = this.getUnit_price();
        result = result * PRIME + ($unit_price == null ? 43 : $unit_price.hashCode());
        result = result * PRIME + this.getStyle();
        result = result * PRIME + this.getCheck_status();
        final Object $refund_status = this.getRefund_status();
        result = result * PRIME + ($refund_status == null ? 43 : $refund_status.hashCode());
        final Object $refund_coin = this.getRefund_coin();
        result = result * PRIME + ($refund_coin == null ? 43 : $refund_coin.hashCode());
        final Object $age_text = this.getAge_text();
        result = result * PRIME + ($age_text == null ? 43 : $age_text.hashCode());
        final Object $gender_text = this.getGender_text();
        result = result * PRIME + ($gender_text == null ? 43 : $gender_text.hashCode());
        final Object $address_1 = this.getAddress_1();
        result = result * PRIME + ($address_1 == null ? 43 : $address_1.hashCode());
        final Object $address_2 = this.getAddress_2();
        result = result * PRIME + ($address_2 == null ? 43 : $address_2.hashCode());
        final Object $address_3 = this.getAddress_3();
        result = result * PRIME + ($address_3 == null ? 43 : $address_3.hashCode());
        final Object $address_text = this.getAddress_text();
        result = result * PRIME + ($address_text == null ? 43 : $address_text.hashCode());
        return result;
    }

    public String toString() {
        return "AdItem(img_url=" + this.getImg_url() + ", total_times=" + this.getTotal_times() + ", today_click=" + this.getToday_click() + ", click_times=" + this.getClick_times() + ", unit_price=" + this.getUnit_price() + ", style=" + this.getStyle() + ", check_status=" + this.getCheck_status() + ", refund_status=" + this.getRefund_status() + ", refund_coin=" + this.getRefund_coin() + ", age_text=" + this.getAge_text() + ", gender_text=" + this.getGender_text() + ", address_1=" + this.getAddress_1() + ", address_2=" + this.getAddress_2() + ", address_3=" + this.getAddress_3() + ", address_text=" + this.getAddress_text() + ")";
    }
}
